<template>
  <div id="me">
    <div class="top">
      <h1 class="title">我的</h1>
    </div>
    <div class="info-box">
      <img class="avatar" src="./images/img_touxiang@2x.png" />
      <div class="info-text">
        <p>{{this.$store.state.user.loginName}}</p>
        <!-- <p><i class="icon"></i><span>{{this.$store.state.user}}</span></p>
        <p><i class="icon"></i><span>1897721212</span></p>-->
      </div>
    </div>
    <div class="click-item-list">
      <router-link :to="{ name: 'UpPassword'}" class="item">
        <p>
          <i class="icon password"></i>
          <span>密码</span>
        </p>
        <i class="icon arrow-icon"></i>
      </router-link>
      <div class="item">
        <p>
          <i class="icon autoLogin"></i>
          <span>自动登录</span>
        </p>
        <van-switch v-model="checked" active-color="#07c160" />
      </div>
      <router-link :to="{ name: 'FaceBack'}" class="item">
        <p>
          <i class="icon faceBack"></i>
          <span>建议与反馈</span>
        </p>
        <i class="icon arrow-icon"></i>
      </router-link>
      <router-link :to="{ name: 'About'}" class="item">
        <p>
          <i class="icon about"></i>
          <span>关于我们</span>
        </p>
        <i class="icon arrow-icon"></i>
      </router-link>
    </div>
    <div class="bottom">
      <van-button @click="outLogin" type="primary" size="large" color="#3A73F6">退出登录</van-button>
    </div>
  </div>
</template>
<script>
import { Dialog } from "vant";

export default {
  data() {
    return {
      checked: false
    };
  },
  methods: {
    outLogin() {
      Dialog.confirm({
        title: "",
        message: "是否确认退出？"
      })
        .then(() => {
           
           localStorage.removeItem("token");
           localStorage.removeItem("userId");
           if(localStorage.getItem("isRemember")!="true"){
               localStorage.removeItem("loginName");
               localStorage.removeItem("password");
           }
          
            this.$store.commit({
                type: "removeUser"
            });
            this.$router.replace({ path: "/" }); // -> /user
        });
     
    }
  }
};
</script>
<style scoped>
.top {
  width: 750px;
  height: 256px;
  background: rgba(58, 115, 246, 1);
  overflow: hidden;
}
.title {
  margin-top: 26px;
  font-size: 36px;
  font-weight: bold;
  color: rgba(255, 255, 255, 1);
  text-align: center;
}
.info-box {
  position: relative;
  top: -140px;
  width: 710px;
  height: 220px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 1);
  border-radius: 16px;
}
.avatar {
  height: 140px;
  width: 140px;
}
.info-box {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 30px 20px;
}

.icon {
  display: inline-block;
  height: 22px;
  width: 22px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  margin-right: 10px;
}

.click-item-list {
  position: relative;
  top: -110px;
  margin: 0 20px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 1);
  border-radius: 16px;
}
.item {
  display: flex;
  flex-direction: row;
  align-items: center;
  border-bottom: 1px solid #e9e9e9;
  padding: 20px 0;
}
.item:nth-last-of-type(1) {
  border: none;
}
.item .icon {
  width: 44px;
  height: 44px;
}
.item p {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex: 1;
}
.item span {
  font-size: 28px;
  color: #333333;
}
.icon.password {
  background-image: url("./images/icon_xiugaimima@2x.png");
}
.icon.faceBack {
  background-image: url("./images/icon_jianyifankui@2x.png");
}
.icon.autoLogin {
  background-image: url("./images/icon_zidongdenglu@2x.png");
}
.icon.about {
  background-image: url("./images/icon_guanyuwomen@2x.png");
}
.icon.arrow-icon {
  height: 32px;
  width: 32px;
  background-image: url("./images/icon_more@2x.png");
}
.info-text {
  flex: 1;
  margin-left: 31px;
}
.info-text p {
  margin-top: 15px;
  font-size: 30px;
  color: #333333;
}
.info-text span {
  font-size: 26px;
  color: #555555;
}
.info-box .icon:nth-of-type(1) {
  background-image: url("./images/img_touxiang@2x.png");
}
.info-box .icon:nth-of-type(2) {
  background-image: url("./images/icon_bumen@2x.png");
}
.bottom {
  margin: 100px 30px 0 30px;
}
</style>